package com.isunland.managesystem.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.isunland.managesystem.R;
import com.isunland.managesystem.entity.OrderNumberList.OrderNumberDetail;
import java.util.List;

public class OrderNumberListAdapter extends ArrayAdapter<OrderNumberDetail> {

  /**
   * ViewHolder class for layout.<br />
   * <br />
   * Auto-created on 2016-01-19 10:39:23 by Android Layout Finder
   * (http://www.buzzingandroid.com/tools/android-layout-finder)
   */
  private static class ViewHolder {
    public final LinearLayout rootView;
    public final TextView tvOrderNum;
    public final TextView tvCustomerNameOrderNumList;
    public final TextView tvOrderStaffName;

    private ViewHolder(LinearLayout rootView, TextView tvOrderNum,
        TextView tvCustomerNameOrderNumList, TextView tvOrderStaffName) {
      this.rootView = rootView;
      this.tvOrderNum = tvOrderNum;
      this.tvCustomerNameOrderNumList = tvCustomerNameOrderNumList;
      this.tvOrderStaffName = tvOrderStaffName;
    }

    public static ViewHolder create(LinearLayout rootView) {
      TextView tvOrderNum = (TextView) rootView.findViewById(R.id.tv_orderNum);
      TextView tvCustomerNameOrderNumList =
          (TextView) rootView.findViewById(R.id.tv_customerName_orderNumList);
      TextView tvOrderStaffName = (TextView) rootView.findViewById(R.id.tv_orderStaffName);
      return new ViewHolder(rootView, tvOrderNum, tvCustomerNameOrderNumList, tvOrderStaffName);
    }
  }

  @Override public View getView(int position, View convertView, ViewGroup parent) {
    final ViewHolder vh;
    if (convertView == null) {
      View view = mInflater.inflate(R.layout.adapter_ordernumber_list, parent, false);
      vh = ViewHolder.create((LinearLayout) view);
      view.setTag(vh);
    } else {
      vh = (ViewHolder) convertView.getTag();
    }

    OrderNumberDetail item = getItem(position);

    vh.tvOrderNum.setText(item.getMoutbillNo());
    vh.tvCustomerNameOrderNumList.setText(item.getMcustomerName());
    vh.tvOrderStaffName.setText(item.getMoutappmanName());

    return vh.rootView;
  }

  private LayoutInflater mInflater;

  // Constructors
  public OrderNumberListAdapter(Context context, List<OrderNumberDetail> objects) {
    super(context, 0, objects);
    this.mInflater = LayoutInflater.from(context);
  }

  public OrderNumberListAdapter(Context context, OrderNumberDetail[] objects) {
    super(context, 0, objects);
    this.mInflater = LayoutInflater.from(context);
  }
}
